/** * 项目一户式预览页面 */
<template>
	<ProjectPreYhsPanel v-bind="options" v-if="validatePass" />
	<span v-else>{{ validateMessage }}</span>
</template>

<script setup name="ProjectYhsPreviewView">
import { defineAsyncComponent, onMounted } from 'vue';
import { NextLoading } from '/@/utils/loading';
import { YHS_PROJ_FORM_CONFIG, FORM_TAB_PANEL_CONFIG } from '@/components/designer/cfg/rk-form-conf.js';

const ProjectPreYhsPanel = defineAsyncComponent(() => import('./components/ProjectPreYhsPanel.vue'));

// ----- 路由相关操作
// 当前路由
const route = useRoute();
const query = route.query;
// console.log('yhsPreview', query)
// 获取一户式配置
const options = ref({});
const validatePass = ref(false);
const validateMessage = ref('');
const setOptions = () => {
	let config = {};
	if (!query.hasOwnProperty('proId')) {
		validateMessage.value = 'proId参数不存在，请确认！';
		return;
	}
	config['proId'] = query.proId;
	if (!query.hasOwnProperty('type')) {
		validateMessage.value = 'type参数不存在，请确认！';
		return;
	}
	if (!query.proId) {
		validateMessage.value = 'proId参数内容不能为空，请确认！';
		return;
	}
	if (!query.type) {
		validateMessage.value = 'type参数内容不能为空，请确认！';
		return;
	}
	// 校验是否存在对应类型的Form表单
	let formConfig = YHS_PROJ_FORM_CONFIG[query.type];
	if (!formConfig) {
		validateMessage.value = 'type参数对应的表单配置不存在，请确认！';
		return;
	}
	config = { ...config, ...formConfig };
	if (query.hasOwnProperty('applyId')) {
		config['applyId'] = query.applyId;
	}
	if (query.type === YHS_PROJ_FORM_CONFIG.AT.value || query.type === YHS_PROJ_FORM_CONFIG.FD.value) {
		config['defaultTabActiveName'] = FORM_TAB_PANEL_CONFIG.JBXX.value;
	}
	validatePass.value = true;
	options.value = {
		...config,
	};
};

// 页面加载时
onMounted(() => {
	NextLoading.done();
});

setOptions();
</script>

<style lang="scss" scoped></style>
